package runtime;

import java.util.HashMap;
import java.util.Map;

import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.deployer.ContextDeployer;
import org.mortbay.jetty.deployer.FileConfigurationManager;
import org.mortbay.jetty.deployer.WebAppDeployer;
import org.mortbay.jetty.handler.ContextHandlerCollection;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class JettyStarter2 {
    public static void main(String[] args) throws Exception {           
        Server server = new Server();
/*      DevEnvironment dev = new DevEnvironment();
        Thread.currentThread().setContextClassLoader( 
                        dev.getClassLoader());
                        // new ImpReloadingClassLoader( JettyStarter.class.getClassLoader()));
*/      
        Connector connector=new SelectChannelConnector();
        connector.setPort(Integer.getInteger("jetty.port",8000).intValue());
        server.setConnectors(new Connector[]{connector});
        WebAppContext webapp = new WebAppContext("WebRoot","/struts2-blank");
        ContextDeployer  contextDeployer=new ContextDeployer();
        contextDeployer.setConfigurationDir("./contexts");
        contextDeployer.setContexts(new ContextHandlerCollection());
        FileConfigurationManager configurationManager=new FileConfigurationManager();
       // configurationManager.setFile("./etc/deployment.properties");
        contextDeployer.setConfigurationManager(configurationManager);
        contextDeployer.setScanInterval(3);
        server.setHandler(webapp);
        server.addLifeCycle(contextDeployer);
        server.start();
        server.join();
    }
}
